#define paginate(currentPage, totalPage, link)
    #if(totalPage <= 0 || currentPage > totalPage) #return #end
    #setLocal(startPage = currentPage - 4)
    #if (startPage < 1) #setLocal(startPage = 1) #end

    #setLocal(endPage = currentPage + 4)
    #if (endPage > totalPage) #setLocal(endPage = totalPage) #end

    <ul class="pagination">
        #if (currentPage <= 10)
        #setLocal(startPage = 1)
        #end
        #if ((totalPage - currentPage) < 10)
        #setLocal(endPage = totalPage)
        #end
        #if (currentPage == 1)
        <li class="prev disabled"><a href="#(link)#(currentPage - 1)#(append)"><i class="icon-double-angle-left"></i></a></li>
        #else
        <li class="prev"><a href="#(link)#(currentPage - 1)#(append)"><i class="icon-double-angle-left"></i></a></li>
        #end
        #for(i : [startPage..endPage])
        #if (currentPage == i)
        <li class="active"><a href="#(link)#(i)#(append)">#(i)</a></li>
        #else
        <li class=""><a href="#(link)#(i)#(append)">#(i)</a></li>
        #end
        #end

        #if (currentPage == totalPage)
        <li class="next disabled"><a href="#"><i class="icon-double-angle-right"></i></a></li>
        #else
        <li class="next"><a href="(link)#(currentPage + 1)#(append)"><i class="icon-double-angle-right"></i></a></li>
        #end
    </ul>
#end